package org.ww.cms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.ww.cms.bean.CrmBanner;
import org.ww.cms.mapper.CrmBannerMapper;
import org.ww.cms.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author ww
 * @since 2020-10-31
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {

    /**
     * 获取所有的banner信息
     * @return
     */
    @Override
    public List<CrmBanner> getAllBanner() {
        //根据id降序查询前两条banner数据
        QueryWrapper<CrmBanner> wrapper=new QueryWrapper<>();
        wrapper.orderByDesc("id");
        wrapper.last("limit 2");  //sql拼接
        return baseMapper.selectList(wrapper);
    }
}
